package com.ruoyi.web.controller.install;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.install.DevSoftware;
import com.ruoyi.system.service.install.IDevSoftwareService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 软件信息Controller
 * 
 * @author ruoyi
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/install/software")
public class DevSoftwareController extends BaseController
{
    @Autowired
    private IDevSoftwareService devSoftwareService;

    /**
     * 查询软件信息列表
     */
    @PreAuthorize("@ss.hasPermi('install:software:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevSoftware devSoftware)
    {
        startPage();
        List<DevSoftware> list = devSoftwareService.selectDevSoftwareList(devSoftware);
        return getDataTable(list);
    }

    /**
     * 导出软件信息列表
     */
    @PreAuthorize("@ss.hasPermi('install:software:export')")
    @Log(title = "导出软件信息列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DevSoftware devSoftware)
    {
        List<DevSoftware> list = devSoftwareService.selectDevSoftwareList(devSoftware);
        ExcelUtil<DevSoftware> util = new ExcelUtil<DevSoftware>(DevSoftware.class);
        util.exportExcel(response, list, "软件信息数据");
    }

    /**
     * 获取软件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('install:software:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(devSoftwareService.selectDevSoftwareById(id));
    }

    /**
     * 新增软件信息
     */
    @PreAuthorize("@ss.hasPermi('install:software:add')")
    @Log(title = "新增软件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevSoftware devSoftware)
    {
        return toAjax(devSoftwareService.insertDevSoftware(devSoftware));
    }

    /**
     * 修改软件信息
     */
    @PreAuthorize("@ss.hasPermi('install:software:edit')")
    @Log(title = "修改软件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevSoftware devSoftware)
    {
        return toAjax(devSoftwareService.updateDevSoftware(devSoftware));
    }

    /**
     * 删除软件信息
     */
    @PreAuthorize("@ss.hasPermi('install:software:remove')")
    @Log(title = "删除软件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(devSoftwareService.deleteDevSoftwareByIds(ids));
    }
}
